/**
 * 骨架屏
 * @author 明浩
 */
import { View } from "@tarojs/components";
import classnames from "classnames";
import styles from "./index.module.less";
import Taro from "@tarojs/taro";

function Skeleton({
  noAnimated,
  bg = "#efefef",
  width = "100%",
  height = "0",
  className,
}: any) {
  return (
    <View
      className={classnames(
        styles["skeleton"],
        { [styles["shan"]]: !noAnimated },
        className
      )}
      style={{
        background: bg,
        width: width.endsWith("%") ? width : Taro.pxTransform(width),
        height: height.endsWith("%") ? height : Taro.pxTransform(height),
      }}
    >
      <View className={styles["block"]} />
    </View>
  );
}

export default Skeleton;
